package cn.inswf.display {
	import flash.display.BitmapData;

	/**
	 * @author lee
	 */
	public class BitmapContainer extends BitmapProxy {
		protected var __x : Number = 0;
		protected var __y : Number = 0;
		protected var __scaleX : Number = 1;
		protected var __scaleY : Number = 1;
		protected var __registrationX : Number = 0;
		protected var __registrationY : Number = 0;
		protected var __rotation : Number = 0;

		public function BitmapContainer(bitmapData : BitmapData = null, pixelSnapping : String = "auto", smoothing : Boolean = false) {
			super(bitmapData, pixelSnapping, smoothing);
		}

		override public function set x(value : Number) : void {
			__x = value;
			super.x = value;
		}

		override public function set y(value : Number) : void {
			__y = value;
			super.y = value;
		}

		override public function set scaleX(value : Number) : void {
			__scaleX = value;
			super.scaleX = value;
		}

		override public function set scaleY(value : Number) : void {
			__scaleY = value;
			super.scaleY = value;
		}

		override public function set rotation(value : Number) : void {
			__rotation = value;
			super.rotation = value;
		}

		override public function set registrationX(value : Number) : void {
			__registrationX = value;
			super.registrationX = value;
		}

		override public function set registrationY(value : Number) : void {
			__registrationY = value;
			super.registrationY = value;
		}

		override public function from(value : BitmapProxy) : void {
			if (value != null) {
				super.bitmapData = value.bitmapData;
				_registrationX = __registrationX + value.registrationX;
				_registrationY = __registrationY + value.registrationY;
				_scaleX = __scaleX * value.scaleX;
				_scaleY = __scaleY * value.scaleY;
				_rotation = __rotation + value.rotation;
				_change = true;
			} else {
				super.bitmapData = null;
			}
		}
	}
}
